/*
 * $Id: Box.java 100 2009-04-30 12:45:50Z meyer@alphatec.de $
 * 
 *
 * Copyright 2009 DeltaDesk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package deltadesk.deepspace.widget.box;

import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.Rectangle;

import deltadesk.gui.deltagui.style.Style;

/**
 * DefaultBoxStyle.
 * 
 * @author Andreas Meyer
 * @version $Revision: 100 $
 */
public class DefaultBoxStyle implements BoxStyle {

	/**
	 * @see deltadesk.deepspace.widget.box.BoxStyle#render(java.awt.Graphics2D, deltadesk.gui.deltagui.style.Style, boolean)
	 */
	public void render(final Graphics2D g2, final Style style, final boolean hasFocus) {

		final Rectangle rect = g2.getClipBounds();
		
		g2.setPaint(new GradientPaint(0, 1, style.getGradientLightColor(), 0,
				rect.height - 2, style.getGradientDarkColor()));
		g2.fillRoundRect(1, 1, rect.width - 2, rect.height - 2, 6, 6);
		
		if(hasFocus) {
			
			g2.setColor(style.getBorderColor());
			g2.drawRoundRect(1, 1, rect.width - 2, rect.height - 2, 6, 6);
		} // end if
	}

}
